<!DOCTYPE html>
<html lang="zh-cn">

<head>
	<meta charset="UTF-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<title>用户管理</title>
	
	<link rel="stylesheet" href="${contextPath}/admin/stylesheets/common.css" />
	<link rel="stylesheet" href="${contextPath}/admin/stylesheets/table.css" />
	<link rel="stylesheet" href="${contextPath}/admin/ext/zTree/css/zTreeStyle/zTree.css" type="text/css" />
	
	<script type="text/javascript" src="${contextPath}/admin/ext/jquery/jquery-1.11.3.min.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/layer_v2/layer.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/jquery/selectbox.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zw/grid.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zw/src/jquery-epaging.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/javascripts/tool-1.1.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zTree/js/jquery.ztree.core-3.5.min.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zw/lui/common.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zw/lui/luicontroller.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/jquery/jquery.nicescroll.min.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/javascripts/zcommon.js?v=${sversion}" basepath="${contextPath}" baseinit="ajaxCheckLogin"></script>
</head>

<body>
	<div class="place">
        <span class="label-span">位置：</span>
        <span>系统设置 - 用户管理</span>
    </div>
	<div class="body-warp clearfix">
		<!-- tree-list 树导航 tree-content树内容-->
		<!-- tree-list 树列表两种展现方式 -->
		<!-- 1.美观滚动条，固定宽度，展开超过长度时省略号表示，悬浮显示全部文字提示，可自定义固定宽度 ,必在要素：嵌套在DIV里，tree-list-scroll类名，nicescroll插件及初始化（初始化时请放置于最后），封装函数createTreeScroll()-->
		<#if login_info.show_yunAdmin || login_info.role==6>
		<div class="tree-list-scroll ztree panel p-10">
			<ul id="treeList">
			</ul>
		</div>
		<!-- 1.浏览器默认滚动条，根据右侧树列表项长度自动调整右侧内容区尺寸,必在要素：tree-list类名，封装函数createTree()-->
		<!--<ul id="treeList" class="tree-list ztree panel p-10">
		</ul>-->
		<div id="treeContent" class="tree-content">
		<#else>
		<div class="body-warp">
		</#if>
			<div class="panel filter-block">
				<form class="form-inline clearfix">
					<div class="form-group">
						<input type="hidden" id="searchDeptId" name="searchDeptId" value="" /> 
	                	帐号昵称：<input id="searchUsername" class="form-control" type="text" />
	                </div>
	                <div class="form-group">
	                	真实姓名：<input id="searchRealname" class="form-control" type="text" />
	                </div>
	                <div class="form-group">
	                	手机号：<input id="searchMobile" class="form-control" type="text" />
	                </div>
		            <div class="form-group">
		            	角色：
	                    <select id="searchRole" class="form-select">
	                        <option value="">--请选择--</option>
	                        <#list role_map.keySet() as key>
	                        	<option value="${key}">${role_map.get(key)}</option>
	                        </#list>
	                    </select>
	                </div>
	                <div class="form-group">
	                    <a href="javascript:void(0);" class="btn" id="search-btn"><i class="iconfont">&#xe61b;</i>搜索</a>
	                </div>
				</form>
			</div>
			<#if Session.login_info.show_yunAdmin>
		        <div class="panel table-tool-bar">
		            <a class="btn" href="###" id="synbtn" onclick="_syn();">用户同步</a>
		            <a class="btn" href="###" style="display:none;" id="waitbtn">正在同步中...</a>
		        </div>
	        </#if>
			<table class="table" id="table"></table>
		</div>
	</div>
	<script>
		var grid = {} ;
		$(function () {
			<#if login_info.show_yunAdmin || login_info.role==6>
			$.post('${contextPath}/dept/findTreeData.do',{},function(data){
				initTree(data);
			},"json");
			</#if>
			/*初始化表格*/
			grid = $('#table').grid({
				store: {
					url: '${contextPath}/user/list.do'
				},
				tool: {
					pagingBar: true
				},
				columns: [{
	                title: '帐号昵称',
	                dataIndex: 'username'
	            },{
	                title: '真实姓名',
	                dataIndex: 'realname'
	            },{
	            	title:'所属组织',
	            	dataIndex:'show_deptName'
	            },{
	                title: '性别',
	                dataIndex: 'sex'
	            },{
	            	title:'手机号',
	            	dataIndex:'mobile'
	            },{
	                title: '角色',
	                dataIndex: 'show_role'
	            }]
			});
			/*侦听*/
			addListeners();
			initWidget();
		});
			
			
		function onClick(event, treeId, treeNode){
			$("#searchDeptId").val(treeNode.id);
			$('#search-btn').trigger("click");
		}

		/*初始化树*/
		function initTree(zNodes) {
			//初始化树
			var setting = {
				async:{
					enable:false
				},
				callback:{
					onClick:onClick
				}
			};
			//全局性树列，默认使用id名为#treeList；树内容区默认使用ID名使用#treeContent，两者绑定，折叠展开树列时，树内容自适应窗口布局
			//当一个页面出现多个树列时，其他树列使用非#treeList名称，如果*还想*绑定树内容自适应窗口，请在setting里的view里绑定treeContentId的ID名称
			//
			/*
			var treeObj = $("#treeList").createTree(setting, zNodes);
			*/
			var treeObj = $("#treeList").createTreeScroll(setting, zNodes);
			//选中第一个子树
			//treeObj.selectNode(treeObj.getNodes()[0].children[0]);

			//#5 查询对象节点上绑定的其他字段 搜索msl

		}
		
		/*初始化控件*/
		function initWidget() {

			//下拉菜单初始化
			$('.form-select').each(function (index, el) {
				selectbox(this);
			});

			//初始化按钮下拉, require tool.js
			$('.ui-droplist').dropList();

			//初始化弹出条信息, require tool.js
			$('.popuptips').popupTips();

			//初始化树滚动条
			$('.tree-list-scroll').niceScroll({
				cursorcolor: '#7db7fb',
				cursorwidth: '6px',
				cursorborderradius: 2,
				autohidemode: true,
				background: '#d0d0d0',
				cursoropacitymin: 1,
				cursorborder: 'none',
				horizrailenabled: true
			});
		}
	
	function addListeners(){
	
	}
	
	$('#search-btn').click(function(){
    	var params = {
			searchDeptId: $('#searchDeptId').val(),
			searchUsername: $('#searchUsername').val(),
			searchRealname: $('#searchRealname').val(),
			searchMobile : $("#searchMobile").val(),
			searchRole: $('#searchRole').val()
    	};
    	grid.load(params);
    });
    $('#searchUsername').keydown(function(e){
		if(e.keyCode==13){
		   $('#search-btn').click();
		   return false;
		}
	});
	$('#searchRealname').keydown(function(e){
		if(e.keyCode==13){
		   $('#search-btn').click();
		   return false;
		}
	});
	$('#searchDeptId').change(function(){
		$('#search-btn').click();
	});
	$('#searchRole').change(function(){
		$('#search-btn').click();
	});
	
	function _syn(){
		if(!confirm("确定要进行用户信息同步吗？")) return false;
		$("#synbtn").attr("style","display:none;");
		$("#waitbtn").removeAttr("style");
		$.post('${contextPath}/index/synData.do',{},function(data){
			if(data.s==1){
				alert("同步成功！");
				grid.refresh();
			}else{
				alert("同步失败！");
			}
			$("#waitbtn").attr("style","display:none;");
			$("#synbtn").removeAttr("style");
		},"json");	
	}
	
	</script>
</body>
</html>